package com.mjk.common.core.rmq.mq;

import lombok.Getter;

import java.util.Objects;

@Getter
public abstract class RunnablePriority implements Runnable, Comparable<RunnablePriority> {


    private final int priority;

    protected RunnablePriority(int priority) {
        this.priority = priority;
    }

    @Override
    public int compareTo(RunnablePriority o) {
        return Integer.compare(o.priority, this.getPriority());
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        RunnablePriority that = (RunnablePriority) o;
        return priority == that.priority;
    }

    @Override
    public int hashCode() {
        return Objects.hash(priority);
    }
}
